<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 3. 统计字符串中每个字符的个数？以对象的形式返回

    var str = 'abcdacbabcbababcbabcabd';
    var res = '';

    for(var i=0;i<str.length;i++){
        if(res.lastIndexOf(str[i]) == -1){
            res += str[i];
        }
    }
    // console.log(res);
    for(var i=0;i<res.length;i++){
        var num = 0;
        for(var j=0;j<str.length;j++){
            if(res[i] == str[j]){
                num++;
            }
        }
        console.log(res[i] + '有' + num + '个');
    }
    // for (var key in num) {
    //         console.log(key + '出现的次数' + res[key]);
    //     }
</script>
</html>